package com.wang.gulimall.order.web;

import com.wang.gulimall.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

/**
 * @author: wan
 */
@Controller
public class HelloController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @ResponseBody
    @GetMapping(value = "/createOrder")
    public String createOrderTest() {

        //订单下单成功
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderSn("111111");
        orderEntity.setModifyTime(new Date());

        //给MQ发送消息
        rabbitTemplate.convertAndSend("order-event-exchange", "order.create.order", orderEntity);
        return "ok";
    }

    @GetMapping(value = {"/{page}.html"})
    public String listPage(@PathVariable("page") String page) {
        return page;
    }

//    @GetMapping(value = {"/confirm.html"})
//    private String indexPage(Model model) {
//        return "confirm";l"})
//    public String loginPage() {
//        return "detail";
//    }
//
//    //登录界面
//    @GetMapping(value = {"/", "/detail.htm
//    }
}
